package com.example.myapplication.SmartElderly;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.MenuItem;

import com.example.myapplication.R;
import com.example.myapplication.SmartElderly.Fragment.Smart_homeFragment;
import com.example.myapplication.SmartElderly.Fragment.Smart_lookFragment;
import com.example.myapplication.SmartElderly.Fragment.Smart_myFragment;
import com.example.myapplication.SmartElderly.Fragment.Smart_whereFragment;
import com.google.android.material.bottomnavigation.BottomNavigationView;

public class SmartElderlyActivity extends AppCompatActivity {

    private BottomNavigationView bat;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_smart_elderly);
        Smart_homeFragment smart_homeFragment = new Smart_homeFragment();
        Smart_lookFragment smart_lookFragment = new Smart_lookFragment();
        Smart_myFragment smart_myFragment = new Smart_myFragment();
        Smart_whereFragment smart_whereFragment = new Smart_whereFragment();
        getSupportFragmentManager().beginTransaction().replace(R.id.layout, smart_homeFragment).commit();
        bat = findViewById(R.id.bat);
        bat.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                switch (item.getItemId()) {
                    case R.id.smart_home:
                        getSupportFragmentManager().beginTransaction().replace(R.id.layout, smart_homeFragment).commit();
                        break;
                    case R.id.smart_where:
                        getSupportFragmentManager().beginTransaction().replace(R.id.layout, smart_whereFragment).commit();
                        break;
                    case R.id.smart_look:
                        getSupportFragmentManager().beginTransaction().replace(R.id.layout, smart_lookFragment).commit();
                        break;
                    case R.id.smart_my:
                        getSupportFragmentManager().beginTransaction().replace(R.id.layout, smart_myFragment).commit();
                        break;
                }
                return true;
            }
        });
    }
}